package com.zhu.cloudspring.service;

import com.zhu.cloudspring.config.RabbitMQConfig;
import com.zhu.cloudspring.entity.Order;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RabbitMQSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendOrderMessage(Order order, String consignee) {
        rabbitTemplate.convertAndSend(RabbitMQConfig.ORDER_EXCHANGE_NAME, RabbitMQConfig.ORDER_ROUTING_KEY,  consignee);
    }
}
